
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class SmallestDistance {
	
	public int GetSmallestDistance(int[] array) {
		int indx = 0;
		int delta;
		int currentDelata;
		
		if(array.length == 1) {
			return -1;
		}
		
		if(array.length == 2) {
			return indx;
		}
		
		delta =  Math.abs(array[0] - array[1]);
		
		for(int i = 1; i < array.length - 1; i++) {
			currentDelata = Math.abs(array[i] - array[i + 1]);
			if(currentDelata < delta) {
				delta = currentDelata;
				indx = i;
			}
		}
		
		return indx;
	}
	
	public static void main(String[] args) {
		int[] result;
                int num;
		StringBuilder myAllInput = new StringBuilder();
		StringBuilder myInputDigit = new StringBuilder();
		SmallestDistance mySmallestDistance = new SmallestDistance();
		
		while(true) {
			try {
				System.out.println("Input one number please or 'exit' to exit (everything else will be discarded!!!):");
				BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
				String str = in.readLine();
				
				if (str.equals("")) {
					continue;
				}
				
				if (str.equals("exit")) {
					break;
				}
				
				for(int i = 0; (i < str.length()) && 
                               (str.charAt(i) != '\t') && 
                               (str.charAt(i) != '\u0020'); i++) {
					myInputDigit.append(str.charAt(i));
				}
				
				num = Integer.parseInt(myInputDigit.toString());
				myInputDigit.delete(0, myInputDigit.length());
                                
				myAllInput.append(num);
				myAllInput.append('\u0020');
				 
			}catch(Exception ex) {
				System.out.println("Try to input number please!!!");
			}
		}
		
                if(myAllInput.length() == 0) {
                    return;
                }
                
		String[] allDigits = myAllInput.toString().split(Character.toString('\u0020')); 
		
		result = new int[allDigits.length];
		
		for (int i = 0; i < result.length; i++) {
                result[i] = Integer.parseInt(allDigits[i]);
		}
		
		System.out.println("Your index:");
		System.out.println(mySmallestDistance.GetSmallestDistance(result));
	}       
}